import os
import sys
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
if project_root not in sys.path:
    sys.path.append(project_root)
    
from readlater.database.db_manager import DatabaseManager
from readlater.config import ConfigManager
from readlater.utils.logger import get_logger


# 启动服务
if __name__ == "__main__":
    logger = get_logger(__name__)
    logger.info("启动服务")

    # 初始化数据库
    config_manager = ConfigManager()
    if config_manager.is_first_run():
        db_manager = DatabaseManager(config_manager.get_database_path())
        db_manager.connect()
        db_manager.create_table()
        db_manager.close()

    logger.info("完成数据库初始化")
    print('''
             *     ,MMM8&&&.            *
                  MMMM88&&&&&    .
                 MMMM88&&&&&&&
     *           MMM88&&&&&&&&
                 MMM88&&&&&&&&
                 'MMM88&&&&&&'
                   'MMM8&&&'      *    
          |\___/|     /\___/\ 
          )     (     )    ~( .              '
         =\     /=   =\~    /=
           )===(       ) ~ (
          /     \     /     \ 
          |     |     ) ~   (
         /       \   /     ~ \ 
         \       /   \~     ~/
  jgs_/\_/\__  _/_/\_/\__~__/_/\_/\_/\_/\_/\_
  |  |  |  |( (  |  |  | ))  |  |  |  |  |  |
  |  |  |  | ) ) |  |  |//|  |  |  |  |  |  |
  |  |  |  |(_(  |  |  (( |  |  |  |  |  |  |     Joan Stark
  |  |  |  |  |  |  |  |\)|  |  |  |  |  |  |
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
                     ''')

